/** 
 * Copyright (C), 2010-2012, AIYOU Software Co.,Ltd. ALL RIGHTS RESERVED. 
 * File name:TestCity.java
 * Version:1.0
 * Date:2011-12-25
 * Description: 
 * author:whh 
 */
package com.tietiao.common.action;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.tietiao.common.bean.AreaBean;
import com.tietiao.common.util.AreaUtil;
import com.tietiao.dao.model.SysDict;
import com.tietiao.service.sysdist.SysDictService;
@Service
public class InitDataBean {
	@Resource
	private SysDictService sysDictService;
	
	public void initData(){
		List<SysDict> sysDicts = sysDictService.getSysDict();
		AreaUtil.areaMap = new HashMap<String,List<AreaBean>>();
		
		for (SysDict sysDict : sysDicts) {
			if("ADMINISTRATIVE_DIVISIONS".equals(sysDict.getRootKey()) && !"".equals(sysDict.getParentKey())){
				if("1".equals(sysDict.getDictLevel())){
					if(AreaUtil.areaMap.containsKey(AreaUtil.ALL_CODE)){
						AreaUtil.areaMap.get(AreaUtil.ALL_CODE).add(AreaBean.getAreaBean(sysDict));
					}else{
						List<AreaBean> list = new ArrayList<AreaBean>();
						list.add(AreaBean.getAreaBean(sysDict));
						AreaUtil.areaMap.put(AreaUtil.ALL_CODE, list);
					}
				}else if("2".equals(sysDict.getDictLevel())){
					if(AreaUtil.areaMap.containsKey(sysDict.getParentKey())){
						AreaUtil.areaMap.get(sysDict.getParentKey()).add(AreaBean.getAreaBean(sysDict));
					}else{
						List<AreaBean> list = new ArrayList<AreaBean>();
						list.add(AreaBean.getAreaBean(sysDict));
						AreaUtil.areaMap.put(sysDict.getParentKey(), list);
					}
				}
			}else{
				
			}
		}
	}
	public static void main(String[] args) {
		new InitDataBean();
		System.out.println("dd");
	}
}
